import { useState } from "react";

function useToggle() {
  const [value, setValue] = useState(true);

  const toggle = () => {
    setValue(!value);
  };

  return [value, toggle] as const;
}

function App() {
  const [value, toggle] = useToggle();
  return (
    <div>
      {value && <div>this is a div</div>}
      <button onClick={toggle}>toggle</button>
    </div>
  );
}

export default App;
